package com.fourfaith.iot.beidou.enums;

/**
 * @Name FkxxEnum
 * @Description 反馈信息
 * @Author shiyunan
 * @Create 2022/3/7 13:50
 */
public enum FkxxEnum {
    /**
     * 反馈信息
     */
    SUCCESS((byte) 0x00, "成功"),
    FAIL((byte) 0x01, "失败"),
    SIGNAL_NOT_LOCKED((byte) 0x02, "信号未锁定"),
    INSUFFICIENT_POWER((byte) 0x03, "电量不足"),
    LAUNCH_FREQUENCY_NOT_REACHED((byte) 0x04, "发射频度未到"),
    ENCRYPTION_OR_DECRYPTION_ERROR((byte) 0x05, "加解密错误"),
    CRC_ERROR((byte) 0x01, "CRC错误"),
    CLOSED((byte) 0xFF, "通道未打开");

    /**
     * 错误编码
     */
    private final byte key;

    /**
     * 错误描述
     */
    private final String desc;

    FkxxEnum(byte key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public byte getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static FkxxEnum getFkxxEnumByKey(int key) {
        for (FkxxEnum fkxx : FkxxEnum.values()) {
            if (fkxx.key == key) {
                return fkxx;
            }
        }
        return null;
    }
}
